﻿using HP.HPTRIM.Service;
using ServiceStack.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DocuSignPlugin
{
    public class BaseDocuSignService : TrimServiceBase
    {
        public const string ENV_GUID = "docusign.envGuid.{0}";

        private TrimHelper _trimHelper = null;
        protected TrimHelper TrimHelper
        {
            get
            {
                if (_trimHelper == null)
                {
                    _trimHelper = new TrimHelper(this.Database, _appSettings);
                }
                return _trimHelper;
            }
        }

        private DocuSignAPIs _docusign = null;
        protected DocuSignAPIs Docusign
        {
            get
            {
                if (_docusign == null)
                {
                    _docusign = new DocuSignAPIs(_appSettings);
                }
                return _docusign;
            }
        }
        protected AppSettings _appSettings;


        public BaseDocuSignService()
        {
            _appSettings = new AppSettings();

        }

        protected string GetEnvGuid(long uri)
        {
            return Session.Get<string>(string.Format(ENV_GUID, uri));
        }

        protected void SetEnvGuid(long uri, string envGuid)
        {
            Session.Set(string.Format(ENV_GUID, uri), envGuid);
        }
    }
}
